package com.cf.base.http.generator;

import com.cf.base.http.bean.ErrorResponse;
import com.cf.base.http.core.RetrofitService;
import com.cf.base.http.engine.JsonEngine;

import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;

/**
 * 错误处理器
 *
 * @author yangji
 */
public abstract class BaseBodyErrorAdapter<T extends ErrorResponse> implements IErrorAdapter {

    /**
     * 67
     * 获取泛型中的内容
     *
     * @return 泛型的类型
     */
    public Class<T> getBaseClass() {
        Class<T> clazz = (Class<T>) ((ParameterizedType) getClass()
                .getGenericSuperclass()).getActualTypeArguments()[0];
        return clazz;
    }

    /**
     * @param bean
     * @param method    出错的方法
     * @param throwable 异常
     * @return
     */
    @Override
    public abstract Throwable call(RetrofitService bean, Method method, Throwable throwable);
}
